import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/Home.vue'),
    children: [
      {
        path: '/home',
        name: 'index',
        component: () => import('@/pages/index.vue')
      },
      {
        path: '/search',
        name: 'search',
        component: () => import('@/pages/search.vue')
      },
      {
        path: '/library',
        name: 'library',
        component: () => import('@/pages/library.vue')
      },
      {
        path: '/mine',
        name: 'mine',
        component: () => import('@/pages/mine.vue')
      },
    ]
  },

  // 详情页
  {
    path: '/detail',
    redirect: '/home',
    name: 'Detail',
    component: () => import('@/views/Detail.vue'),
    children: [
      {
        path: '/detail/artists',
        name: 'artists',
        component: () => import('@/detail/artists.vue'),
      },
      {
        path: '/detail/songs',
        name: 'songs',
        component: () => import('@/detail/songs.vue'),
      },
      {
        path: '/detail/playlist',
        name: 'playlist',
        component: () => import('@/detail/playlist.vue'),
      },
      {
        path: '/detail/album',
        name: 'album',
        component: () => import('@/detail/album.vue'),
      },
    ]
  },

  // 登录页
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue')
  },
]

const router = new VueRouter({
  // 历史模式
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
